import React, { useEffect, useState } from 'react'

export default function App() {
  let [person,setPerson]=useState([
    {
      id:'001',
      name:'张三'
  },{
    id:'002',
    name:'李四'
},{
  id:'003',
  name:'王五'
}
])

useEffect(()=>{
  console.log('preson改变了');
},[person])


const  addPresonHandle=()=>{
  setPerson([...person,{id:Date.now(),name:'小小钟'}])
}
  return (
    <div>
      <button onClick={addPresonHandle}>添加数据</button>
      <ul>
        {
          person.map(item=>{
          return  <li key={item.id}>{item.name}</li>
          })
        }
      </ul>
    </div>
  )
}
